package com.sunyard.weixi.javacookies;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Properties;

/**
 * 配置文件读取类
 * Created by xic on 2015/12/24.
 */
public class PropertiesUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesUtils.class);
    /**
     * 读取指定路径下的配置文件
     * @param path 文件路径
     * @return
     */
    public static Properties loadProperties(String path){
        Properties properties = new Properties();
        try {
            path = URLDecoder.decode(path, "UTF-8");
            properties.load(new FileInputStream(new File(path)));
        } catch (FileNotFoundException e) {
            LOGGER.debug("找不到该properties配置文件", e);
        } catch (IOException e) {
            LOGGER.debug("转换成流失败", e);
        }
        return properties;
    }
}
